import React from 'react';
import { Space } from 'antd';
import { getColumnSearchProps } from '../../Common/TableSearch';
import { TableDropdown, type ProColumns } from '@ant-design/pro-components';
import {
  SearchOutlined,
} from "@ant-design/icons";

export type APGroupTableListItem = {
  key: string;
  groupId: string;
  groupName: string;
  createAt: string;
  devCounts: string;
  moreAction: React.ReactNode;
};

const testData: APGroupTableListItem[] = [];

for (let i = 0; i < 25; i += 1) {
  testData.push({
    key: i.toString(),
    groupId: i.toString(),
    groupName: `分组${i}`,
    createAt: `2014-12-24 23:12:0${i}`,
    devCounts: `${i}/${i + 1}`,
    moreAction: (
      <Space>
        <a>删除</a>
        <a>编辑</a>
        <a>查看</a>
        <TableDropdown
          key="actionGroup"
          menus={[
            { key: 'allrestart', name: '重启' },
            { key: 'allreset', name: '重置' },
            { key: 'allupgrade', name: '升级' },
          ]}
        />
      </Space>
    ),
  });
}

const GroupListFileds: ProColumns<APGroupTableListItem>[] = [
  {
    title: '分组ID',
    dataIndex: 'groupId',
    ...getColumnSearchProps('groupId'),
    render: (value: any, record: any, index: number) => {
      return <span>{value}</span>;
    },
    filterIcon: (filtered) => (
      <SearchOutlined style={{ color: filtered ? '#1890ff' : undefined }} />
    ),
  },
  {
    title: '分组名称',
    dataIndex: 'groupName',
    ...getColumnSearchProps('groupName'),
    render: (value: any, record: any, index: number) => {
      return <span>{value}</span>;
    },
    filterIcon: (filtered) => (
      <SearchOutlined style={{ color: filtered ? '#1890ff' : undefined }} />
    ),
  },
  {
    title: '创建日期',
    dataIndex: 'createAt',
    render: (value: any, record: any, index: number) => {
      return <span>{value}</span>;
    },
    sorter: (a: any, b: any) => {
      const aTime = new Date(a.createAt).getTime();
      const bTime = new Date(b.createAt).getTime();
      return aTime - bTime;
    },
  },
  {
    title: '设备数量(在线/离线)',
    dataIndex: 'devCounts',
    render: (value: any, record: any, index: number) => {
      return <span>{value}</span>;
    }
  },
]

//channel
const channel2_4 = [
  {
    value: 'auto',
    label: '自动'
  },
  {
    value: 1,
    label: '1 (2412 MHz)'
  },
  {
    value: 2,
    label: '2 (2417 MHz)'
  },
  {
    value: 3,
    label: '3 (2422 MHz)'
  },
  {
    value: 4,
    label: '4 (2427 MHz)'
  },
  {
    value: 5,
    label: '5 (2432 MHz)'
  },
  {
    value: 6,
    label: '6 (2437 MHz)'
  },
  {
    value: 7,
    label: '7 (2442 MHz)'
  },
  {
    value: 8,
    label: '8 (2447 MHz)'
  },
  {
    value: 9,
    label: '9 (2452 MHz)'
  },
  {
    value: 10,
    label: '10 (2457 MHz)'
  },
  {
    value: 11,
    label: '11 (2462 MHz)'
  },
  {
    value: 12,
    label: '12 (2467 MHz)'
  },
  {
    value: 13,
    label: '13 (2472 MHz)'
  }
];

const channel5_8 = [
  {
    value: 'auto',
    label: '自动'
  },
  {
    value: 36,
    label: '36 (5180 MHz)'
  },
  {
    value: 40,
    label: '40 (5200 MHz)'
  },
  {
    value: 44,
    label: '44 (5220 MHz)'
  },
  {
    value: 48,
    label: '48 (5240 MHz)'
  },
  {
    value: 52,
    label: '52 (5260 MHz)'
  },
  {
    value: 56,
    label: '56 (5280 MHz)'
  },
  {
    value: 60,
    label: '60 (5300 MHz)'
  },
  {
    value: 64,
    label: '64 (5320 MHz)'
  },
  {
    value: 149,
    label: '149 (5745 MHz)'
  },
  {
    value: 153,
    label: '153 (5765 MHz)'
  },
  {
    value: 157,
    label: '157 (5785 MHz)'
  },
  {
    value: 161,
    label: '161 (5805 MHz)'
  },
  {
    value: 165,
    label: '165 (5825 MHz)'
  }
];

const htmode2_4 = [
  {
    value: 'auto',
    label: '自动'
  },
  {
    value: 'HT20',
    label: '20 MHz'
  },
  {
    value: 'HT40',
    label: '40 MHz'
  }
];

const htmode5_8 = [
  {
    value: 'auto',
    label: '自动'
  },
  {
    value: 'HT20',
    label: '20 MHz'
  },
  {
    value: 'HT40',
    label: '40 MHz'
  },
  {
    value: 'HT80',
    label: '80 MHz'
  },
  {
    value: 'HT160',
    label: '160 MHz'
  }
];

const wifiDefaultValues = {
  radio2_4: {
      disabled: true,
      channel: 'auto',
      htmode: 'auto',
      hwmode: 'auto',
      txpower: 21
  },
  radio5_8: {
      disabled: true,
      channel: 'auto',
      htmode: 'auto',
      hwmode: 'auto',
      txpower: 23
  },
  ssid2_4: {
    ssid2_4_1:{
      disabled: true,
      hidden: false,
      ssid:'WiFi-Base-2G-1',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid2_4_2:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-2G-2',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid2_4_3:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-2G-3',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid2_4_4:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-2G-4',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
  },
  ssid5_8: {
    ssid5_8_1:{
      disabled: true,
      hidden: false,
      ssid:'WiFi-Base-5G-1',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid5_8_2:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-5G-2',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid5_8_3:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-5G-3',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
    ssid5_8_4:{
      disabled: false,
      hidden: false,
      ssid:'WiFi-Base-5G-4',
      encryption: 'mixed-psk2-ccmp',
      key: 'wifibase',
      vlanid: 0,
    },
  }
};

const ssid_encryption = [
  { value: 'none', label: '无密码' },
  { value: 'mixed-psk2-ccmp', label: 'WPA/WPA2-PSK' },
  { value: 'psk2-ccmp', label: 'WPA2-PSK' },
  { value: 'psk-ccmp', label: 'WPA-PSK' }
];

const columnsConfig2_4 = [
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid2_4', label: 'WiFi-1', order: '1' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid2_4', label: 'WiFi-2', order: '2' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid2_4', label: 'WiFi-3', order: '3' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid2_4', label: 'WiFi-4', order: '4' }
];

const columnsConfig5_8 = [
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid5_8', label: 'WiFi-1', order: '1' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid5_8', label: 'WiFi-2', order: '2' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid5_8', label: 'WiFi-3', order: '3' },
  { xs: 16, sm: 16, md: 16, lg: 12, xl: 12, name: 'ssid5_8', label: 'WiFi-4', order: '4' }
];

export {
  testData,
  channel2_4,
  channel5_8,
  htmode2_4,
  htmode5_8,
  columnsConfig2_4,
  columnsConfig5_8,
  ssid_encryption,
  wifiDefaultValues,
  GroupListFileds,
};